package com.cgah

import javax.xml.bind.annotation.XmlAccessType
import javax.xml.bind.annotation.XmlAccessorType
import javax.xml.bind.annotation.XmlRootElement


@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "customer")
class Customer extends com.cgah.User {

	Date createdDate;
	//String userName;

	// customer can have many bids
    static mappedBy = [listings:'seller', winnings:'winner'];
	static hasMany = [listings:Listing, winnings:Listing, bids:Bid];


	static constraints = {
		// must be unique, must be the form *@*.*
		createdDate(nullable: false);
		listings(nullable: true);
        winnings(nullable: true);
	}

    boolean canDelete()
    {
        return ((this.bids == null || this.bids.empty) && (this.listings == null || this.listings.empty))
    }

}
